import request from '@/utils/request'
import { praseStrEmpty } from '../../../../utils/ruoyi'

// 查询列表
export function listUserGroup(query) {
  return request({
    url: '/system/group/selectSysUserGroupList',
    method: 'get',
    params: query
  })
}

// 查询列表
export function listUserInGroup(query) {
  return request({
    url: '/system/group/userGroupList',
    method: 'get',
    params: query
  })
}

// 查询列表
export function treeUserGroup(query) {
  return request({
    url: '/system/group/treeSelect',
    method: 'get',
    params: query
  })
}

// 查询详细
export function getUserGroup(groupId) {
  return request({
    url: '/system/group/' + praseStrEmpty(groupId),
    method: 'get'
  })
}

// 新增
export function addUserGroup(data) {
  return request({
    url: '/system/group',
    method: 'post',
    data: data
  })
}

// 新增用户到用户组
export function addUserToGroup(data) {
  return request({
    url: '/system/group/insertGroupRelevanceByIds',
    method: 'post',
    data: data
  })
}

// 修改
export function updateUserGroup(data) {
  return request({
    url: '/system/group',
    method: 'put',
    data: data
  })
}

// 修改 权限
export function updateGroupControl(data) {
  return request({
    url: '/system/group/editPermissions',
    method: 'put',
    data: data
  })
}

// 删除
export function delGroup(groupId) {
  return request({
    url: '/system/group/' + groupId,
    method: 'delete'
  })
}
